<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateTreatmentsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('treatments', function (Blueprint $table) {
            $table->bigIncrements('id')->unique()->comment('主键ID');
            $table->string('name')->unique()->comment('疗程名');
            $table->integer('mins')->comment('时长');
            $table->integer('new_price')->comment('促销价');
            $table->integer('old_price')->comment('原价');
            $table->string('poster_url')->comment("海报图片地址");
            $table->string('thumb_url')->comment("缩略图片地址");
            $table->unsignedBigInteger('treatment_categories_id')->comment('疗程分类ID');
            $table->foreign('treatment_categories_id')->references('id')->on('treatment_categories');
            $table->tinyInteger('is_show_home')->default(1)->comment('是否展示在首页，1为展示，0为不展示');
        });

        DB::statement("ALTER TABLE `treatments` comment '关键信息表'");
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('treatments');
    }
}
